package facilius.controller.actionmanager;

import facilius.controller.ActionManager;
import facilius.controller.action.nota.NotaCreateAction;
import facilius.controller.action.nota.NotaDeleteAction;
import facilius.controller.action.nota.NotaReadAction;
import facilius.controller.action.nota.NotaReportAction;
import facilius.controller.action.nota.NotaShowFormAction;
import facilius.controller.action.nota.NotaUpdateAction;
import org.mentawai.authorization.Permission;
import org.mentawai.core.ActionConfig;
import org.mentawai.core.ApplicationManager;
import org.mentawai.core.Forward;
import org.mentawai.core.Redirect;
import org.mentawai.core.StreamConsequence;
import org.mentawai.filter.AuthorizationFilter;

/**
 *
 * @author Graciano
 */
public class NotaActionManager implements ActionManager{

    public void loadActions(ApplicationManager appManager) {
        ActionConfig ac = null;
        ac = new ActionConfig("NotaRead",NotaReadAction.class);
        ac.addConsequence(appManager.SUCCESS, new Forward("jsp/valorNota/valorNotaList.page"));
        ac.addConsequence(appManager.ERROR, new Forward("jsp/erro.page"));
        ac.addFilter(new AuthorizationFilter(new Permission("nota")));
        appManager.addActionConfig(ac);

        ac = new ActionConfig("NotaShowForm",NotaShowFormAction.class);
        ac.addConsequence(appManager.SUCCESS, new Forward("jsp/valorNota/valorNotaForm.page"));
        ac.addConsequence(appManager.ERROR, new Forward("jsp/erro.page"));
        ac.addFilter(new AuthorizationFilter(new Permission("nota")));
        appManager.addActionConfig(ac);

        ac = new ActionConfig("NotaCreate", NotaCreateAction.class);
        ac.addConsequence(appManager.SUCCESS, new Redirect("NotaRead.mtw"));
        ac.addConsequence(appManager.ERROR, new Forward("jsp/erro.page"));
        ac.addFilter(new AuthorizationFilter(new Permission("nota")));
        appManager.addActionConfig(ac);

        ac = new ActionConfig("NotaDelete",NotaDeleteAction.class);
        ac.addConsequence(appManager.SUCCESS, new Redirect("NotaRead.mtw"));
        ac.addConsequence(appManager.ERROR, new Forward("jsp/erro.page"));
        ac.addFilter(new AuthorizationFilter(new Permission("nota")));
        appManager.addActionConfig(ac);

        ac = new ActionConfig("NotaUpdate",NotaUpdateAction.class);
        ac.addConsequence(appManager.SUCCESS, new Redirect("NotaRead.mtw"));
        ac.addConsequence(appManager.ERROR, new Forward("jsp/erro.page"));
        ac.addFilter(new AuthorizationFilter(new Permission("nota")));
        appManager.addActionConfig(ac);

        ac = new ActionConfig("NotaReportAction",NotaReportAction.class);
        ac.addConsequence(appManager.SUCCESS, new StreamConsequence("application/pdf"));
        ac.addConsequence(appManager.ERROR, new Forward("jsp/erro.page"));
        ac.addFilter(new AuthorizationFilter(new Permission("nota")));
        appManager.addActionConfig(ac);

    }

}
